#ifndef BONDDETAILALLMARKET_H
#define BONDDETAILALLMARKET_H

#include <QWidget>
#include <qbprotocol/include/SSQBModel.h>

namespace Ui {
class BondDetailAllMarket;
}

class DetailData;
class BestBidOfr;
class SVirtualTable;
class STableColumnSet;
class DetailQuoteTable;
class BondDetailPrcInter;
class BondDetailAllMarket : public QWidget
{
    Q_OBJECT

public:
    enum QuoteTypeId {
        AllMarket = 0,	//全市场
        Broker,	//经纪商行情
        CFETS,	//cfets
        Exchange,	//交易所
        SHFixed,	//上证固收
        //Primary = 0,//一级行情
        QuoteTypeCount
    };
    Q_ENUM(QuoteTypeId);

    enum FilterTypeId {
        TickByTick = 0,
        TodaysDeals,
    };

    explicit BondDetailAllMarket(QWidget *parent = nullptr);
    ~BondDetailAllMarket();

    void setDetailData(QSharedPointer<DetailData>);
    bool setBrokerTab(int nBrokerId);
    void setQuoteType(QuoteTypeId type, const std::vector<bool>& mask);
private:
    void initBestPriceList();
    void updateList();

    void updateDisplayMktStream(QuoteTypeId type);

protected:
    void paintEvent(QPaintEvent* event) override;
private slots:
    //void onBestPriceChanged(std::map<std::string, int> changes);
    void on_ClearSpeed_currentTextChanged(const QString &arg1);

    void on_cmbSource_currentTextChanged(const QString &arg1);

    void onBondChanged();

    void onSHFIDataArrived(const QList<xQBSHFIQuoteUnit_c>& datas);

private:
    Ui::BondDetailAllMarket *ui;

private:
    int m_clearSpeed = 0;
    std::vector<xQBMarketStreamUnit_c> m_mktStream[QuoteTypeCount];
    QuoteTypeId m_quote_type = QuoteTypeCount;
    QuoteTypeId m_source_type = QuoteTypeCount;
    FilterTypeId m_filter_type = TickByTick;
    QSharedPointer<DetailData> m_data = nullptr;

private:
    BestBidOfr* m_bestBidOfr = nullptr;
    SVirtualTable* m_bestTable = nullptr;
    STableColumnSet* m_bestTableSet = nullptr;
};

#endif // BONDDETAILALLMARKET_H
